<?php 
	include './init.php';
	$model=new Model('user_info');
	$uid=$_SESSION['user']['id'];

	$a=$_GET['a'];
	switch ($a) 
	{
		case 'add':
			//判断是否为空
		//var_dump($_FILES);exit;
		
			$_POST['face']=$_FILES['face']['name'];
		//var_dump($_POST);
			if (!empty($_POST)) 
			{
				foreach ($_POST as $key => $value) 
				{
					if (empty($value)) 
					{
						error('表单没有填写完整！',10000);
						return false;
					}
				}
			}

			//判断图片是否上传
			if ($_FILES['face']['error']>0) 
			{
				error('图片上传失败！');
				return false;
			}

			//接受数据
			$data['uid']=$uid;
			$data['name']=$_POST['name'];
			$data['age']=$_POST['age'];
			$data['birthday']=$_POST['birthday'];
			$data['sex']=$_POST['sex']==2?0:1;
			$data['tel']=$_POST['tel'];
			$data['qq']=$_POST['qq'];
			$data['email']=$_POST['email'];
			//上传图片，返回图片的name
			$filename=Upload('face',PATH.'/public/uploads/');
			//var_dump($filename);
			$data['face']=$filename;

			//插入商品表返回商品的id
			$info_id=$model->insert($data);

			if ($info_id) 
			{
				success('个人信息已完善！',URL.'/personal_info.php',1);
					return false;
			}
			break;
		
	}
?>